﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Cinema_Ticketing_System.Models
{
    public class Cinema_Name
    {
        CinemaDBEntities2 cdb = new CinemaDBEntities2();
        /// <summary>
        /// 根据地区Id所有属于该地区的电影院
        /// </summary>
        /// <param name="areaid"></param>
        /// <returns></returns>
        public List<cinema_table> GetCinemaName(int areaid ,string keys,int cid)
        {
            List<cinema_table> cinemaList = cdb.cinema_table.ToList();
            if (areaid != -99)
            {
                cinemaList = cinemaList.Where(x => x.cinemaarea==areaid).ToList();

            }
            if (keys != null)
            {
                cinemaList = cinemaList.Where(x => x.cinemaname.Contains(keys) || x.cinemaaddress.Contains(keys)).ToList();
            }
            if (cid != -100)
            {
                cinemaList = cinemaList.Where(x => x.cinemaid == cid).ToList();

            }
            return cinemaList;
        }
    }
}